set apkname=%1
set projectName=%apkname:.apk=%
set signroot=%cd%
set certificate=%2

cd bin
if not exist %projectName%.apk goto apkNotExist
if not exist %signroot%\%certificate%.pk8 goto certNotExist


echo resign %projectName%.apk use certificate %certificate%

if exist %projectName%.apk goto resignapk

:resignapk
java -jar %signroot%\signapk.jar %signroot%\%certificate%.x509.pem %signroot%\%certificate%.pk8 %projectName%.apk %signroot%\out\%projectName%.apk
echo === success
exit

:apkNotExist
echo === failed, %projectName%.apk not exist!
exit

:certNotExist
echo === failed, %signroot%\%certificate%.pk8 not exist!
exit





